package com.lkc.controller;

import com.lkc.domain.ResponseResult;
import com.lkc.domain.dto.AddQuestionDto;
import com.lkc.domain.dto.AnswerDto;
import com.lkc.domain.entity.Question;
import com.lkc.service.QuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Title: QuestionController
 * @Author 椰咩咩
 * @Package com.lkc.controller
 * @Date 2022/12/27 14:55
 * @description: 题目（question）的控制层
 */
@RestController
@RequestMapping("/question")
public class QuestionController {

    @Autowired
    private QuestionService questionService;

    @GetMapping("/examed/{eId}")
    public ResponseResult getExamedQuestions(@PathVariable Long eId) {
        return questionService.getExamedQuestions(eId);
    }

    @GetMapping("/{eId}")
    public ResponseResult getQuestions(@PathVariable Long eId) {
        return questionService.getQuestions(eId);
    }

    @DeleteMapping("/exam/{qId}/{eId}")
    public ResponseResult delFromExam(@PathVariable Long qId, @PathVariable Long eId) {
        return questionService.delFromExam(qId, eId);
    }

    @PostMapping("/exam")
    public ResponseResult addQuestionToExam(@RequestBody Question question) {
        return questionService.addQuestionToExam(question);
    }

    @PutMapping
    public ResponseResult updateQuestion(@RequestBody Question question) {
        return questionService.updateQuestion(question);
    }

    @PostMapping("/checkAnswer")
    public ResponseResult checkAnswer(@RequestBody AnswerDto answerDto) {
        return questionService.checkAnswer(answerDto);
    }

}
